package com.powervision.mvvmdemo.ui.viewmodel

import com.powervision.base.base.BaseViewModel
import com.powervision.base.util.LogUtils
import com.powervision.http.observer.StateLiveData
import com.powervision.mvvmdemo.ui.model.BannerModel
import com.powervision.mvvmdemo.ui.repository.BannerRepository

/**
 * @auth: njb
 * @date: 2021/12/17 17:46
 * @desc: 描述
 */
class BannerViewModel : BaseViewModel() {
    val mBannerLiveData = StateLiveData<List<BannerModel>>()

    private val mBannerRepository by lazy { BannerRepository() }

    fun getBanner() {
        launchWithLoading(requestBlock = {
            mBannerRepository.banner()
        }, resultCallback = { it ->
            mBannerLiveData.value = it
            it.data?.forEach {
                LogUtils.d("--bannerList--", it.imagePath.toString())
            }
        })
    }
}